<template>
  <div class="app-container">
    <Find :OriginalFilter="{ static: true }" :formList="formList" @findClicked="findClicked" />
    <!-- 数据列表 -->
    <el-card shadow="never" :body-style="{ padding: '10px 10px 10px' }" class="mt10">
      <div slot="header" class="f16">
        <span style="font-weight: 600">订单明细资料</span>
      </div>
      <Table :tableHeader="tableHeader" :tableData="tableData" stripe :TableHeight="100" :outTableHeight="80" class="mt10" />
      <!-- 分页器 -->
      <PageModule :PageData="{ total }" @pageSizeChange="handleSizeChange" @pageChange="handleCurrentChange" />
    </el-card>
  </div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { reactive, ref } from 'vue'
import 'dayjs/locale/zh-cn'
import JMessage from '@/utils/JMessage'
export default defineComponent({
  name: 'CollectionNodeQueryKl'
})
</script>
<script lang="ts" setup>
import { i18n, Jzhcn } from '@/i18n'
import Api from '@/api/GeneralManager/inquire/Acquisitionnode'
import { onMounted, watch } from 'vue'
import { TableList, selectList, type TableListType } from '@/plugins/mixin'
const formList = ref([
  {
    type: 'input',
    inputPlaceholder: '请输入指令',
    inputValue: '',
    inputLabel: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '品牌',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '请输入工厂货号',
    inputValue: '',
    inputLabel: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '季节',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '样品类型',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'date',
    dateLabel: '客户交期',
    dateValue: ''
  },
  {
    type: 'date',
    dateLabel: '下单日期',
    dateValue: ''
  },
  {
    type: 'date',
    dateLabel: '出货日期',
    dateValue: ''
  },
  {
    type: 'checkbox',
    checkboxLabel: '未完成',
    checked: true
  },
  {
    type: 'checkbox',
    checkboxLabel: '已完成',
    checked: true
  },

  {
    type: 'button',
    checkboxLabel: '清空'
  },
  {
    type: 'button',
    checkboxLabel: '导出'
  }
])
const currentPage = ref(1)
const pageSize = ref(40)
const total = ref(0)
const tableData = ref([])
const imgList = ref<string[]>([])
const getTableList = async () => {
  let { Data, dataList, srcList } = (await TableList(formList, Api.getTableList, currentPage.value, pageSize.value)) as TableListType
  tableData.value = dataList
  total.value = Data.total
  imgList.value = srcList
  console.log(dataList)
}
const getSelectList = async () => {
  await selectList(formList, Api.getSelectList)
}
onMounted(async () => {
  getTableList()
  getSelectList()
})

const handleSizeChange = (val: number) => {
  pageSize.value = val
  getTableList()
}
const handleCurrentChange = (val: number) => {
  currentPage.value = val
  getTableList()
}
watch(
  () =>
    formList.value.map((item: any) => {
      item.selectValue, item.inputValue, item.dateValue, item.checked
    }),
  () => {
    getTableList()
  }
)

const findClicked = (content: string) => {
  formList.value.forEach((item) => {
    item.inputValue = ''
    item.selectValue = ''
    item.dateValue = ''
  })
  getTableList()
}

const tableHeader = ref([
  {
    label: '下单日期',
    prop: 'orderDate'
  },
  {
    label: '品牌',
    prop: 'brand'
  },
  {
    label: '指令号',
    prop: 'lotNo'
  },
  {
    label: '工厂货号',
    prop: 'style'
  },
  {
    label: '颜色',
    prop: 'color'
  },
  {
    label: '号码',
    prop: 'sizeNo'
  },
  {
    label: '数量',
    prop: 'orderQty'
  },
  {
    label: '样品类型',
    prop: 'sampleType'
  },
  {
    label: '客户交期',
    prop: 'deliveryDate'
  },
  {
    bgColor: '#00ff00',
    label: '裁剪工艺检核',
    prop: 'cutCheck'
  },
  {
    bgColor: '#00ff00',
    label: '新旧改版',
    prop: 'newOld'
  },
  {
    bgColor: '#00ff00',
    label: '版房',
    prop: 'boardRoom'
  },
  {
    bgColor: '#00ff00',
    label: '主料',
    prop: 'mainIn'
  },
  {
    bgColor: '#00ff00',
    label: '针铺',
    prop: 'acu'
  },
  {
    bgColor: '#00ff00',
    label: '裁断',
    prop: 'cut'
  },
  {
    bgColor: '#00ff00',
    label: '电雕',
    prop: 'elcEngv'
  },
  {
    bgColor: '#00ff00',
    label: '无缝',
    prop: 'seamless'
  },
  {
    bgColor: '#00ff00',
    label: '印刷',
    prop: 'print'
  },
  {
    bgColor: '#00ff00',
    label: '高频',
    prop: 'hf'
  },
  {
    bgColor: '#00ff00',
    label: '配套',
    prop: 'matchs'
  },
  {
    bgColor: '#00ff00',
    label: '针车',
    prop: 'stitch'
  },
  {
    bgColor: '#00ff00',
    label: '大底',
    prop: 'sole'
  }
])
</script>

<style lang="less" scoped>
// 底部
.bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;

  .total {
    font-size: 14px;
    color: rgba(0, 0, 0, 0.6);
    font-family: PingFangSC-Regular-, PingFangSC-Regular;
  }

  :deep(.el-input__wrapper) {
    padding: 0;
  }

  :deep(.el-input__suffix) {
    transform: translateX(-9px);
  }

  :deep(.el-pagination .el-select .el-input) {
    width: 88px;
  }

  :deep(.number) {
    border: 1px solid #dcdcdc;
    margin-right: 8px;
    border-radius: 3px 3px 3px 3px;
  }

  :deep(.is-active.number) {
    background-color: #f89027 !important;
    color: white;
    border-radius: 3px 3px 3px 3px;
  }

  .save {
    color: black;
    border: 1px solid #e7e7e7;
    background: #e7e7e7;
  }
}
</style>
